import java.util.Scanner;
import java.util.HashMap;

public class StudentSystem {
    private static HashMap<String, Integer> scoreMap = new HashMap<>();
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while(true) {
            System.out.println("\n=== 学生成绩管理系统 ===");
            System.out.println("1. 记录学生成绩");
            System.out.println("2. 查询学生成绩");
            System.out.println("3. 退出系统");
            System.out.print("请选择功能(1-3)：");
            
            int choice = scanner.nextInt();
            scanner.nextLine(); // 清除缓冲区
            
            switch(choice) {
                case 1:
                    recordScore(scanner);
                    break;
                case 2:
                    queryScore(scanner);
                    break;
                case 3:
                    System.out.println("系统已退出");
                    scanner.close();
                    System.exit(0);
                default:
                    System.out.println("输入无效，请重新选择！");
            }
        }
    }
    
    private static void recordScore(Scanner scanner) {
        System.out.println("\n--- 记录学生成绩 ---");
        System.out.print("请输入学生姓名：");
        String name = scanner.nextLine();
        System.out.print("请输入成绩(0-100)：");
        int score = scanner.nextInt();
        scanner.nextLine(); // 清除缓冲区
        
        scoreMap.put(name, score);
        System.out.println("成绩录入成功！");
    }
    
    private static void queryScore(Scanner scanner) {
        System.out.println("\n--- 查询学生成绩 ---");
        System.out.print("请输入要查询的学生姓名：");
        String name = scanner.nextLine();
        
        if(scoreMap.containsKey(name)) {
            System.out.println(name + "的成绩是：" + scoreMap.get(name));
        } else {
            System.out.println("找不到该学生的成绩记录");
        }
    }
}